﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class HoriDuctAndPipeFilter : ISelectionFilter
	{
		public bool AllowElement(Element elem)
		{
			if (elem is Pipe)
			{
				if (!YJKRevitTools.isRiserPipe(elem as Pipe))
				{
					return true;
				}
			}
			else if (elem is Duct)
			{
				LocationCurve locationCurve = (elem as Duct).Location as LocationCurve;
				double value = locationCurve.Curve.GetEndPoint(0).X - locationCurve.Curve.GetEndPoint(1).X;
				double value2 = locationCurve.Curve.GetEndPoint(0).Y - locationCurve.Curve.GetEndPoint(1).Y;
				return Math.Abs(value) >= 0.0001 || Math.Abs(value2) >= 0.0001;
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}
}
